"""
Custom exceptions for GCR Solver Manager.
"""

from typing import Optional, Any, Dict


class GSMError(Exception):
    """Base exception for all GCR Solver Manager errors."""
    
    def __init__(
        self, 
        message: str, 
        error_code: Optional[str] = None,
        details: Optional[Dict[str, Any]] = None
    ):
        super().__init__(message)
        self.message = message
        self.error_code = error_code
        self.details = details or {}

    def __str__(self) -> str:
        if self.error_code:
            return f"[{self.error_code}] {self.message}"
        return self.message


class ConfigurationError(GSMError):
    """Raised when there's an issue with configuration."""
    pass


class BuildError(GSMError):
    """Raised when build operations fail."""
    pass


class TestError(GSMError):
    """Raised when test operations fail."""
    pass


class DatabaseError(GSMError):
    """Raised when database operations fail."""
    pass


class LogError(GSMError):
    """Raised when log operations fail."""
    pass


class AnalysisError(GSMError):
    """Raised when analysis operations fail."""
    pass


class RemoteExecutionError(GSMError):
    """Raised when remote execution fails."""
    pass


class SlurmError(GSMError):
    """Raised when SLURM operations fail."""
    pass


class ValidationError(GSMError):
    """Raised when validation fails."""
    pass